/* 
 * File:   BRIC.h
 * Author: nata
 *
 * Created on March 13, 2012, 3:30 PM
 */

#ifndef BRIC_H
#define	BRIC_H

#include "Node.h"
#include "Image.h"
#include "Solver.h"
#include "Generator.h"
#include "Scorer.h"
#include "Renderer.h"
#include <opencv/cv.h>
#include <map>
#include <vector>

using namespace std;

class BRIC {
private:
    int width;
    int height;
    int alpha;
    int beta;
    int L;
    Solver solver;
    Generator generator;
    Scorer* scorer;
    Renderer renderer;
    
    //void generate_tree(Node* root, Node* paramActual, Node* leaf, vector<Node* >* trees, Orientation orientation);
/*    void apply_dimensions(Node* raiz, map<Node*, int>* mapa, CvMat* x, Orientation orientation);
    void calculate_bissections(CvMat* A, CvMat* B, Node* raiz, map<Node*, int>* mapa, Orientation orientacaoSolucao);
    void calculate_node(CvMat* A, CvMat* B, Node* no, Node* raiz, map<Node*, int>* mapa, Orientation orientacaoSolucao, bool oposto);
    void mapear(Node* no, map<Node*, int>* mapa);
    void modify(Node* root, double a);
*/
public:
    BRIC(int width, int height, int alpha, int beta, int L); //, Scorer* scorer);
    //void set_scorer(Scorer* scorer);
    double score(Node* root);
    Node* create_tree(vector<Image*>* images);
    Node* create_tree_new(vector<Image*>* images);
    void create_trees(vector<Image*> images, double p, vector<Node*>* nodes);
    void solve(Node* root);
    void generate_trees(Node* root, Node* paramActual, Node* leaf, vector<Node* >* trees);
    vector<Node*>* generate(vector<Image*>* images);
    void solve(vector<Node*>* trees);
    void clean_up(vector<Node*>* trees);
    void generate(map<double, vector<Node*>*>* generated, vector<double>* priorities, vector<Node*>* trees);
    void solve(Node* root, Orientation orientation);
    void fix(Node* root);
    bool priority_respect(Node* root);
    bool bounds_respect(Node* root);
    bool valid_solve(Node* root);
};

#endif	/* BRIC_H */

